/*
   Copyright (c) 2010 Bryce Alcock

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.com

 */

package com.ecocrypt.environment;

/**
 *
 * @author bryce.alcock
 */
public class Info {
    public static final double MIN_VERSION = 1.6;

    private static Boolean isMinimumVersion = null;
    /**
     * Determine if the system is at the minimum version or not.
     * @return
     */
    public static boolean isMinVersion(){
        if(isMinimumVersion!=null){
            return isMinimumVersion;
        }
        //  This feature can only be added in java 1.6....
        String s = System.getProperty("java.runtime.version");
        boolean isMinVersion = false;
        try{
            double d = Double.parseDouble(s.substring(0,3));
            if(d>=MIN_VERSION){
                isMinVersion = true;
//                System.out.println("We have a java 1.6 or higher version.");
            }else{
                System.out.println("Your Version is less than: "+MIN_VERSION+" SOME FEATURES ARE DISABLED! your version "+s);
            }
        }catch(Exception e){
            System
                    .out.println("Unable to determine Java Version because " + String.valueOf(s)
                    + " is not able to be parsed correctly with \n "+e.getMessage());
        }
        isMinimumVersion = isMinVersion;
        return isMinVersion;
    }
}
